var express = require('express');
var bodyParser = require('body-parser');
var app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:false}));

app.post('/tokens/login',function(req,res){
  console.log(req.body);
    var data = {
        "code": 0,
        "describe": "成功",
        "data": {
          "cardNo": "1234567890123456789",
          "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXlsb2FkIjoiXCIxMjM0NTY3ODkwMTIzNDU2Nzg5XCIifQ.Dri6-deBfaoIBl4_SP20XAT4Y5MJ1Xpycy53YBU6-sw"
        }
      }
      var send = JSON.stringify(data);
      res.send(send);
})
app.post('/test',function(req,res) {
    res.send('{"data":"8091"}');
});
app.post('/tokens/logout',function(req,res){
    console.log((req.headers));
    res.end();
})

app.get('/business/query/accountBalance',function(req,res) {
    console.log(req.headers);
    var data = {
        "code": 0,
        "describe": "成功",
        "data": {
          "currentBalance": 29600,
          "availableBalance": 29600
        }
      }
    res.send(JSON.stringify(data));
});

app.get('/business/query/statement',function(req,res) {
  var data = {
    "code": 0,
    "describe": "成功",
    "data": [
      {
        "id": 1,
        "transactionNo": "NO201902211206184221000002061465139",
        "account": "1234567890123456789",
        "postscript": "存款",
        "toAccount": null,
        "deviceNo": "100",
        "amount": 100,
        "currencyType": "CNY",
        "fee": 0,
        "balance": 29500,
        "date": "2019-02-21 12:06:18"
      },
      {
        "id": 2,
        "transactionNo": "NO201902211207032041000000501311107",
        "account": "1234567890123456789",
        "postscript": "存款",
        "toAccount": null,
        "deviceNo": "100",
        "amount": 500,
        "currencyType": "CNY",
        "fee": 0,
        "balance": 30000,
        "date": "2019-02-21 12:07:03"
      }
    ]
  }
  res.send(JSON.stringify(data));
});
app.post('/business/deposit',function(req,res){
  var data = {
    "code": 0,
    "describe": "成功",
    "data": {
      "adviceId": 5,
      "amount": 5000,
      "count": 50
    }
  }
  res.send(JSON.stringify(data));
});
app.post('/business/withdraw',function(req,res){
  var data = {
    "code": 0,
    "describe": "成功",
    "data": {
      "adviceId": 8
    }
  }
  res.send(JSON.stringify(data));
});
app.post('/business/transfer/checkToAccount',function(req,res) {
  var data = {
    "code": 0,
    "describe": "成功",
    "data": {
      "tocardNo": "0987654321098765432",
      "username": "lee"
    }
  }
  res.send(JSON.stringify(data));
});
app.post('/business/transfer/checkpwd',function(req,res) {
  var  data = {
    "code": 0,
    "describe": "成功",
    "data": {
      "adviceId": 13
    }
  }
  res.send(JSON.stringify(data));
});
app.listen(8091);